/*
*	Copyright (C) 2014  Julio Montes, Mario Carrillo
*
*	Julio Montes e-mail: imc.coder@gmail.com
*
*	Mario Carrillo e-mail: mario_90ago@live.com.mx
*
*	BSD 3-Clause License
*/

#ifndef ALLIANCE_PROJECT_H
#define ALLIANCE_PROJECT_H

#include <wx/wx.h>

#include "sdk/include/filecfg.h"

#include "alliance/include/tool.h"

namespace alliance
{
    typedef struct projectFile
    {
        wxString m_filename;
        wxString m_virtualDirectory;
    }projectFile;

    class Project
    {
    public:
        Project();
        virtual ~Project();

        bool LoadFile( const wxString &filename );

        bool ReloadFile( const wxString &filename );

        bool Save();

        void Compile();

        void AddTool( const alliance::Tool &tool );

        void RemoveAllTools();

        /**
        * @brief Add a file
        *
        * if the file already exists, remove and re-add this, to avoid duplicates
        */
        void AddFile( const wxString &filePath, const wxString &virtualDirectory=wxEmptyString );

        bool RemoveFile( const wxString &filePath );

        /**
        * @brief Rename a file in project directory and into the project
        */
        bool RenameFile( const wxString &filePath, const wxString &newFilePath );

        const std::vector<projectFile> &GetFiles() const;

        const std::vector<Tool> &GetTools() const;

        const wxString &GetFilename() const;

        const wxString &GetDirectory() const;

        const wxString &GetName() const;

        bool IsModified() const;

        bool IsBusy() const;
    protected:
    private:
        std::vector<Tool> m_vectorTools;
        std::vector<projectFile> m_vectorFiles;
        wxString m_filename;
        wxString m_projectName;
        wxString m_directory;
        bool m_isModified;
        bool m_isBusy;

        void AddFile( const sdk::mapAttributes &attributes );

        static void CallBackCompile( bool wasCanceled, size_t indexTool, void *caller );
    };
}

#endif //ALLIANCE_PROJECT_H
